﻿@model IEnumerable<ECatalog.Models.Shop>

@{
    ViewBag.Title = "Index";
}
<div class="container">
    <div class="row">
        <p>
            @Html.ActionLink("Добавить магазин", "Create", null, new { @class = "btn btn-primary" })
        </p>
        <table class="table table-bordered table-hover">
            <tr>
                <th>Название
                </th>
                <th>Карта
                </th>
                <th>Описание
                </th>
                <th>Организация
                </th>
                <th></th>
            </tr>

            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>
                    <td>
                        @{
                            var imageUrl = "";
                            if (Model != null)
                            {
                                imageUrl = string.Format("/Files/Organization-{0}/Shop-{1}/{2}/320x240/{3}{4}", @item.OrganizationId, @item.ShopId, @item.MapUrl, @item.MapUrl,@item.TypeImage);
                            }
                        }
                        <img class="photo-block" src="@imageUrl" alt="" />
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Description)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Organization.Name)
                    </td>
                    <td>
                        @Html.ActionLink("Редактировать", "Edit", new { id = item.ShopId }) |
                        
                         @using (Html.BeginForm("Delete", "Shop", new { id = item.ShopId }))
                         {
                             <input type="submit" value="Удалить" class="btn btn-link" />
                         }
                    </td>
                </tr>
            }

        </table>
    </div>
</div>
